package com.sebarmeli.pages;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.WebDriver;

public class PageManager{
	WebDriver driver;
	public LoginPage loginPage;
	public FilmsHomePage filmsHomePage;
	public AddFilmPage addFilmPage;
	public FoundOnImdbPage foundOnImdbPage;
	public DeleteFilmPage deleteFilmPage;
	
	public PageManager(WebDriver driver)
	{
		this.driver=driver;
		loginPage=initElements(new LoginPage(this));
		filmsHomePage=initElements(new FilmsHomePage(this));
		addFilmPage=initElements(new AddFilmPage(this));
		foundOnImdbPage=initElements(new FoundOnImdbPage(this));
		deleteFilmPage=initElements(new DeleteFilmPage(this));
	}
	private <T extends Page> T initElements(T page)
	{
		//PageFactory.initElements(driver,page);
		PageFactory.initElements(new DisplayedElementLocatorFactory(driver,10), page);
	    return page;
		
	}
	public WebDriver getWebDriver()
	{return driver;}


}
